package com.beans;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
/*
* 使用构造方法实现 Bean 的注入
 */
@Controller
public class UserController3 {

    private UserService userService;

    // 构造方法注入（官方推荐）
    @Autowired
    //构造方法
    public UserController3(UserService userService){
        this.userService = userService;
    }

    public void sayHi(){
        userService.sayHi();
    }


}
